package net.tv90.business.service.impl;

import net.tv90.business.dao.StudentMapper;
import net.tv90.business.dao.TeacherMapper;
import net.tv90.business.model.domain.Student;
import net.tv90.business.model.domain.Teacher;
import net.tv90.business.model.dto.StudentAddDTO;
import net.tv90.business.model.dto.TeacherAddDTO;
import net.tv90.business.service.ManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ManageServiceImpl implements ManageService {

    @Autowired
    TeacherMapper teacherMapper;

    @Autowired
    StudentMapper studentMapper;

    @Override
    public void addTeacher(TeacherAddDTO dto) {
        Teacher teacher = Teacher.builder()
                .realName(dto.getRealName())
                .idCard(dto.getIdCard())
                .academy(dto.getAcademy())
                .phone(dto.getPhone())
                .build();
        teacherMapper.insert(teacher);
    }

    @Override
    public void addStudent(StudentAddDTO dto) {
        Student student = Student.builder()
                .realName(dto.getRealName())
                .idCard(dto.getIdCard())
                .academy(dto.getAcademy())
                .major(dto.getMajor())
                .clazz(dto.getClazz())
                .build();
        studentMapper.insert(student);
    }
}
